<!--
 * @Author: 鱿鱼溪学院
 * @Date: 2025-05-09 01:50:19
 * @LastEditTime: 2025-05-09 01:50:50
 * @LastEditors: 鱿鱼溪学院
 * @Description: 
 * @FilePath: \yyx-web\src\components\common\Aa.vue
 * Copyright 鱿鱼溪学院 by edu v1.0
 * 天道酬勤
-->
<!-- 父组件 Parent.vue -->
<template>
  <Child ref="childRef" />
  <button @click="handleClick">调用子组件方法</button>
</template>

<script setup>
import { ref } from 'vue'
import Child from './Child.vue'

const childRef = ref(null) // Ref 名称需与模板中一致

const handleClick = () => {
  // 使用可选链操作符避免未挂载时报错
  childRef.value?.show()
}
</script>
